package com.ruoyi.web.controller.basicInformation;

import java.util.List;
import java.util.Arrays;

import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.basicInformation.vo.TAisTerminalVo;
import com.ruoyi.system.basicInformation.bo.TAisTerminalQueryBo;
import com.ruoyi.system.basicInformation.bo.TAisTerminalAddBo;
import com.ruoyi.system.basicInformation.bo.TAisTerminalEditBo;
import com.ruoyi.system.basicInformation.service.ITAisTerminalService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * AIS终端Controller
 * 
 * @author ruoyi
 * @date 2021-05-25
 */
@Api(value = "AIS终端控制器", tags = {"AIS终端管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/basicInformation/aisTerminal")
public class TAisTerminalController extends BaseController {

    private final ITAisTerminalService iTAisTerminalService;

    /**
     * 查询AIS终端列表
     */
    @ApiOperation("查询AIS终端列表")
    @PreAuthorize("@ss.hasPermi('basicInformation:aisTerminal:list')")
    @GetMapping("/list")
    public TableDataInfo<TAisTerminalVo> list(TAisTerminalQueryBo bo) {
        startPage();
        List<TAisTerminalVo> list = iTAisTerminalService.queryList(bo);
        return getDataTable(list);
    }

    /**
     * 导出AIS终端列表
     */
    @ApiOperation("导出AIS终端列表")
    @PreAuthorize("@ss.hasPermi('basicInformation:aisTerminal:export')")
    @Log(title = "AIS终端", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<TAisTerminalVo> export(TAisTerminalQueryBo bo) {
        List<TAisTerminalVo> list = iTAisTerminalService.queryList(bo);
        ExcelUtil<TAisTerminalVo> util = new ExcelUtil<TAisTerminalVo>(TAisTerminalVo.class);
        return util.exportExcel(list, "AIS终端");
    }

    /**
     * 获取AIS终端详细信息
     */
    @ApiOperation("获取AIS终端详细信息")
    @PreAuthorize("@ss.hasPermi('basicInformation:aisTerminal:query')")
    @GetMapping("/{id}")
    public AjaxResult<TAisTerminalVo> getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(iTAisTerminalService.queryById(id));
    }

    /**
     * 新增AIS终端
     */
    @ApiOperation("新增AIS终端")
    @PreAuthorize("@ss.hasPermi('basicInformation:aisTerminal:add')")
    @Log(title = "AIS终端", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody TAisTerminalAddBo bo) {
        return toAjax(iTAisTerminalService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改AIS终端
     */
    @ApiOperation("修改AIS终端")
    @PreAuthorize("@ss.hasPermi('basicInformation:aisTerminal:edit')")
    @Log(title = "AIS终端", businessType = BusinessType.UPDATE)
    @PutMapping()
    public AjaxResult<Void> edit(@RequestBody TAisTerminalEditBo bo) {
        return toAjax(iTAisTerminalService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除AIS终端
     */
    @ApiOperation("删除AIS终端")
    @PreAuthorize("@ss.hasPermi('basicInformation:aisTerminal:remove')")
    @Log(title = "AIS终端" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult<Void> remove(@PathVariable Long[] ids) {
        return toAjax(iTAisTerminalService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
    }
}
